//
//  Home_NewsViewControllerWeb.m
//  EggSteward
//
//  Created by 王道林 on 16/8/31.
//  Copyright © 2016年 王道林. All rights reserved.
//

#import "Home_NewsViewControllerWeb.h"

@interface Home_NewsViewControllerWeb ()

@end

@implementation Home_NewsViewControllerWeb

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self createSubView];
}

- (void)createSubView
{
    UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 64 - 49)];
    webView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:webView];
    webView.scalesPageToFit = NO;
   
    if ([_name isEqualToString:@"cycle"])
    {
        // home的轮播图的接口
       [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:_url]]];
        self.navigationItem.title = _navigationTitle;
    }
    else if ([_name isEqualToString:@"map"])
    {
        // 地图
        [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://101.200.213.61:81/home/map/earth"]]];
        self.navigationItem.title = _navigationTitle;
    }
    else if ([_name isEqualToString:@"price"])
    {
        // 鸡蛋曲线
        [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://101.200.213.61:81/home/map/chart"]]];
        self.navigationItem.title = _navigationTitle;
    }
    else if ([_name isEqualToString:@"TurnTable"])
    {
        // 转盘
        NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
        
        NSString *uid = [userDefault valueForKey:@"uid"];
        NSString *url = [NSString stringWithFormat:@"http://api.danjiguanjia.com/active/index/active/uid/%@", uid];
        [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
        self.navigationItem.title = _navigationTitle;
    }
    else if ([_name isEqualToString:@"actionCycle"])
    {
        // 活动现场的轮播图点击
        [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:_url]]];
        self.navigationItem.title = _navigationTitle;
    }
    else if ([_name isEqualToString:@"shopGoodsDetail"])
    {
        NSString *url = [NSString stringWithFormat:@"http://www.jianong.com/shop/index/goodsdetail/id/%@/token/43d98b2e7b3577f6fdfea1e26f61efae", _newsId];
        [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
        self.navigationItem.title = _navigationTitle;
    }
    else if ([_name isEqualToString:@"actionNearOne"] || [_name isEqualToString:@"actionNearTwo"])
    {
        // 附近活动
        [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:_url]]];
        self.navigationItem.title = _navigationTitle;
    }
    else if ([_name isEqualToString:@"raw"])
    {
        // 原料曲线
        [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.danjiguanjia.com/home/map/chart_mate"]]];
        self.navigationItem.title = _navigationTitle;
    }
    else if ([_name isEqualToString:@"官网"])
    {
        [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:_url]]];
        webView.scalesPageToFit = YES;
    }
    else
    {
        //  home 下面新闻的接口.需要拼接
        NSString *urlString = [NSString stringWithFormat:@"http://101.200.213.61:81/home/news/view?id=%@", _newsId];
        [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlString]]];
        self.navigationItem.title = _navigationTitle;
    }
    
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
